﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.Custom;
using DWF.Studio.ISerivces;
using DWF.Studio.ScriptEngine.IPC;
using DWF.Studio.ScriptEngine.IPC.Msg;
using DWF.Studio.ScriptEngine.IPC.WorkFlow;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DWF.Studio.Script
{
    /// <summary>
    /// 脚本执行器接口
    /// </summary>
    internal interface IScriptExecutor : IDisposable
    {
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="projectDirectory"></param>
        /// <param name="scriptPath"></param>
        /// <returns>执行id</returns>
        string Execute(string projectDirectory, string scriptPath);

        /// <summary>
        /// 附带参数 执行
        /// </summary>
        /// <param name="projectDirectory"></param>
        /// <param name="scriptPath"></param>
        /// <param name="param"></param>
        /// <returns>执行id</returns>
        string Execute(string projectDirectory, string scriptPath, Dictionary<string, object> param);

        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="projectDirectory"></param>
        /// <param name="scriptPath"></param>
        /// <returns>执行id</returns>
        string Debug(string projectDirectory, string scriptPath, bool isStepOver);

        /// <summary>
        /// 附带参数 执行
        /// </summary>
        /// <param name="projectDirectory"></param>
        /// <param name="scriptPath"></param>
        /// <param name="param"></param>
        /// <returns>执行id</returns>
        string Debug(string projectDirectory, string scriptPath, Dictionary<string, object> param, bool isStepOver);

        /// <summary>
        /// 退出
        /// </summary>
        void Cancel();

        /// <summary>
        /// 设置搜索路径
        /// </summary>
        /// <param name="paths"></param>
        void SetSearchPaths(string[] paths);

        /// <summary>
        /// 设置加载程序集名
        /// </summary>
        /// <param name="paths"></param>
        void SetLoadAssemblyNames(string[] assemblyNames);

        void SetProjectProperties(Func<Dictionary<string, string>> projectPropertiesFunc);

        void DebugResume();

        void CallDebugInfos();

        /// <summary>
        /// 调试进入
        /// </summary>
        void DebugStepInto();

        /// <summary>
        /// 调试跳出
        /// </summary>
        void DebugStepOut();

        /// <summary>
        /// 调试跨步
        /// </summary>
        void DebugStepOver();

        void RefreshBreakpoint(string scriptPath);

        /// <summary>
        /// 执行中止
        /// </summary>
        Action<ScriptExcuteAbortedEventArgs> ExecuteAborted { get; set; }

        /// <summary>
        /// 执行完成
        /// </summary>
        Action<ScriptExcuteCompletedEventArgs> ExecuteCompleted { get; set; }

        /// <summary>
        /// 执行中 未处理异常
        /// </summary>
        Action<ScriptExcuteUnhandledExceptionEventArgs> ExecuteOnUnhandledException { get; set; }

        /// <summary>
        /// 执行追踪
        /// </summary>
        Action<ScriptExecuteTrackEventArgs> ExecuteTrack { get; set; }

        Action<FrameInfoBase> DebugTrack { get; set; }

        Action<HitBreakpointEventArgs> HitBreakpoint { get; set; }

        Action<ExecuteStartEventArgs> ExecuteStart { get; set; }

        Action<ExecuteEndEventArgs> ExecuteEnd { get; set; }

        Action<SubScriptExecuteStartEventArgs> SubScriptExecuteStart { get; set; }

        Action<SubScriptExecuteEndEventArgs> SubScriptExecuteEnd { get; set; }
    }
}
